package com.linkgap.cloud.service;

import com.linkgap.cloud.entity.Clazz;
import com.linkgap.cloud.repo.ClazzRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class ClazzService {
    @Autowired
    private ClazzRepo clazzRepo;

    /**
     * 传入老师id,查询班级表，返回班级的id列表
     */
    public List<Long> queryClazzIdByTeacherId(Long teacherId) {
        // jpa 的命名规范
        List<Clazz> clazzList = clazzRepo.findByMainTeacher(teacherId);
        //区别一下数据和集合  从设值和取值两个方面
        List<Long> clazzIdList = new ArrayList<>();
        for (Clazz clazz : clazzList) {
            Long clazzId = clazz.getId();
            clazzIdList.add(clazzId);
        }
        return clazzIdList;
    }

}
